#include "ble_err.h"

static const char *esp_gap_ble_cb_event_map[] = {
	"ESP_GAP_BLE_ADV_DATA_SET_COMPLETE_EVT",
	"ESP_GAP_BLE_SCAN_RSP_DATA_SET_COMPLETE_EVT",
	"ESP_GAP_BLE_SCAN_PARAM_SET_COMPLETE_EVT",
	"ESP_GAP_BLE_SCAN_RESULT_EVT",
	"ESP_GAP_BLE_ADV_DATA_RAW_SET_COMPLETE_EVT",
	"ESP_GAP_BLE_SCAN_RSP_DATA_RAW_SET_COMPLETE_EVT",
	"ESP_GAP_BLE_ADV_START_COMPLETE_EVT",
	"ESP_GAP_BLE_SCAN_START_COMPLETE_EVT",
	"ESP_GAP_BLE_AUTH_CMPL_EVT",
	"ESP_GAP_BLE_KEY_EVT",
	"ESP_GAP_BLE_SEC_REQ_EVT",
	"ESP_GAP_BLE_PASSKEY_NOTIF_EVT",
	"ESP_GAP_BLE_PASSKEY_REQ_EVT",
	"ESP_GAP_BLE_OOB_REQ_EVT",
	"ESP_GAP_BLE_LOCAL_IR_EVT",
	"ESP_GAP_BLE_LOCAL_ER_EVT",
	"ESP_GAP_BLE_NC_REQ_EVT",
	"ESP_GAP_BLE_ADV_STOP_COMPLETE_EVT",
	"ESP_GAP_BLE_SCAN_STOP_COMPLETE_EVT",
	"ESP_GAP_BLE_SET_STATIC_RAND_ADDR_EVT",
	"ESP_GAP_BLE_UPDATE_CONN_PARAMS_EVT",
	"ESP_GAP_BLE_SET_PKT_LENGTH_COMPLETE_EVT",
	"ESP_GAP_BLE_SET_LOCAL_PRIVACY_COMPLETE_EVT",
	"ESP_GAP_BLE_REMOVE_BOND_DEV_COMPLETE_EVT",
	"ESP_GAP_BLE_CLEAR_BOND_DEV_COMPLETE_EVT",
	"ESP_GAP_BLE_GET_BOND_DEV_COMPLETE_EVT",
	"ESP_GAP_BLE_READ_RSSI_COMPLETE_EVT",
	"ESP_GAP_BLE_UPDATE_WHITELIST_COMPLETE_EVT",
	"ESP_GAP_BLE_UPDATE_DUPLICATE_EXCEPTIONAL_LIST_COMPLETE_EVT",
	"ESP_GAP_BLE_SET_CHANNELS_EVT",
	"ESP_GAP_BLE_EVT_MAX",
};

const char *esp_gap_ble_cb_event_name(esp_gap_ble_cb_event_t event) {
	return (event >= 0 && event <= ESP_GAP_BLE_EVT_MAX) ? esp_gap_ble_cb_event_map[event] : "(Invalid)";
}


typedef struct {
	esp_gatts_cb_event_t event;
    const char *msg;
} esp_gatts_cb_event_t_map_t;

static const char *esp_gatts_cb_event_map[] = {
	"ESP_GATTS_REG_EVT",
	"ESP_GATTS_READ_EVT",
	"ESP_GATTS_WRITE_EVT",
	"ESP_GATTS_EXEC_WRITE_EVT",
	"ESP_GATTS_MTU_EVT",
	"ESP_GATTS_CONF_EVT",
	"ESP_GATTS_UNREG_EVT",
	"ESP_GATTS_CREATE_EVT",
	"ESP_GATTS_ADD_INCL_SRVC_EVT",
	"ESP_GATTS_ADD_CHAR_EVT",
	"ESP_GATTS_ADD_CHAR_DESCR_EVT",
	"ESP_GATTS_DELETE_EVT",
	"ESP_GATTS_START_EVT",
	"ESP_GATTS_STOP_EVT",
	"ESP_GATTS_CONNECT_EVT",
	"ESP_GATTS_DISCONNECT_EVT",
	"ESP_GATTS_OPEN_EVT",
	"ESP_GATTS_CANCEL_OPEN_EVT",
	"ESP_GATTS_CLOSE_EVT",
	"ESP_GATTS_LISTEN_EVT",
	"ESP_GATTS_CONGEST_EVT",
	// Extras
	"ESP_GATTS_RESPONSE_EVT",
	"ESP_GATTS_CREAT_ATTR_TAB_EVT",
	"ESP_GATTS_SET_ATTR_VAL_EVT",
	"ESP_GATTS_SEND_SERVICE_CHANGE_EVT",
};

const char *esp_gatts_cb_event_name(esp_gatts_cb_event_t event) {
	return (event >= 0 && event <= ESP_GATTS_SEND_SERVICE_CHANGE_EVT) ? esp_gatts_cb_event_map[event] : "(Invalid)";
}
